<!DOCTYPE html>
<html lang="zh-CN">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<title>{block name="title"}点赚金-欢迎用户-{$Think.session.user_name}{/block}</title>

<!--js-->
<script src="__ASSETS__/js/jquery-1.8.2.min.js"></script>
<script src="__ASSETS__/js/common.js"></script>
<script src="__ASSETS__/js/jquery.easing.1.3.js"></script>
<script src="__ASSETS__/js/ddsmoothmenu.js"></script>
<script src="__ASSETS__/js/jquery.flexslider.js"></script>
<script src="__ASSETS__/js/jquery.elastislide.js"></script>
<script src="__ASSETS__/js/jquery.jcarousel.min.js"></script>
<script src="__ASSETS__/js/jquery.accordion.js"></script>
<script src="__ASSETS__/js/light_box.js"></script>
<script src="__ASSETS__/lib/bootstrap/js/bootstrap.js"></script>
<script type="text/javascript">$(document).ready(function(){$(".inline").colorbox({inline:true, width:"50%"});});</script>
<!--end js-->

<!-- Mobile Specific Metas ================================================== -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

<!-- CSS ================================================== -->

<link rel="stylesheet" href="__ASSETS__/css/style.css">
<link rel="stylesheet" href="__ASSETS__/css/colors.css">
<link rel="stylesheet" href="__ASSETS__/css/skeleton.css">
<link rel="stylesheet" href="__ASSETS__/css/layout.css">
<link rel="stylesheet" href="__ASSETS__/css/ddsmoothmenu.css"/>
<link rel="stylesheet" href="__ASSETS__/css/elastislide.css"/>
<link rel="stylesheet" href="__ASSETS__/css/home_flexslider.css"/>
<link rel="stylesheet" type="text/css" href="__ASSETS__/lib/bootstrap/css/bootstrap.css">

</head>
<body>
	<div class="mainContainer sixteen container">
            <!--Header Block-->
            <div class="header-wrapper">
              <header class="container">
                <div class="head-right">
                      <ul class="top-nav">
                        {if condition="$Think.session.user_id eq null"}
                          <li class="log-in"><a href="{:url('index/login')}" title="Log In">登录/注册</a></li>
                          {else/}
                          <li><a onclick="getUserInfo('{$Think.session.user_id}')" title="My Account">我的账户</a></li>
                          <li><a data-toggle="modal" data-target="#recharge_user">充值</a></li>
                          <li><a data-toggle="modal" data-target="#applyCash_user">提现</a></li>
                          <li><a href="{:url('userdo/logout')}" title="Log In">退出</a></li>
                        {/if}
                      </ul>
                    <div class="search-block">
                      <input id="search" type="text" placeholder="搜索" onchange="search()" />
                    </div>
                </div>
                <h1 class="logo"><a href="index.html" title="Logo">
                  <img title="Logo" alt="Logo" src="__ASSETS__/images/dianzhuanjin.png" />
                  </a></h1>
                <nav id="smoothmenu1" class="ddsmoothmenu mainMenu">
                  <ul id="nav">
                    <li class=""><a title="Home">商品分类</a>
                      <ul>
                        {volist name="categorys" id="category"}
                          <li><a href="{:url('index/index')}?category_id={$category.category_id}">{$category.category_name}  ({$category.num})  </a></li>
                        {/volist}
                      </ul>
                    </li>
                    {if condition="$Think.session.user_id neq null"}
                    <li class=""><a href="{:url('commoditydo/getBuyCommodity')}" title="Footwear">我购买的</a></li>
                    {/if}
                  </ul>
                </nav>
              </header>
            </div>
            {block name="pageBody"}
            {/block}
    </div> 
    <!--Quick view Block-->
    <script>
    function getUserInfo(user_id){
      $.getJSON("{:url('userdo/getuserInfo')}",{user_id:user_id},function(data){
        var user = data.data;
        $("#UserInfo input[name='user_name']").val(user.user_name);
        $("#UserInfo input[name='user_phone']").val(user.user_phone);
        $("#UserInfo input[name='user_email']").val(user.user_email);
        $("#UserInfo input[name='user_balance']").val(user.user_balance);
        $("#UserInfo input[name='gmt_create']").val(user.gmt_create);
        $('#user_info').modal('show');
      })
    }

    function getPics(commodity_id){
    $.getJSON("{:url('commoditydo/getCommodityPic')}",{commodity_id:commodity_id},function(data){
      $("#Pics").html("");
      if(0 == data.code){
        var pictures = data.data;
        for(var i=0;i<pictures.length;i++){
          $("#Pics").append("<li><img style='width:100px' src='"+pictures[i].picture_address+"'></li>");
        }
        $('#show_pic').modal('show');
      }else{
        alert("获取图片失败");
      }
    });
    }

    function editUser(){
    var form = new FormData(document.getElementById("UserInfo"));
      $.ajax({
          url:"{:url('userdo/edituser')}",
          type:"post",
          data:form,
          processData: false,                // jQuery不要去处理发送的数据
          contentType: false,
          dataType: 'json',
          success:function(data){
             if (0 == data.code) {
                alert("修改成功！");
              }else{
                alert(data.msg);
              }
             
          }
      }); 
    }

    function search(){
      var to = "search?word="+$("#search").val();
      location.href = to;
    }
  </script>
    <div id="user_info" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
      <h3 id="myModalLabel">个人信息</h3>
    </div>
    <form id="UserInfo" onchange="editUser()" class="form-horizontal" onsubmit="return false;">
      <br>
      <div class="control-group">
              <label class="control-label">账户名</label>
              <div class="controls">
                <input type="text" name="user_name" readonly><br>
            </div>
          </div>
          <div class="control-group">
              <label class="control-label">手机号</label>
              <div class="controls">
                <input type="text" name="user_phone"><br>
            </div>
          </div>
      <div class="control-group">
              <label class="control-label">邮箱</label>
              <div class="controls">
                <input type="text" name="user_email"><br>
            </div>
          </div>
          <div class="control-group">
              <label class="control-label">账户余额</label>
              <div class="controls">
                <input type="text" name="user_balance" readonly> 元<br>
            </div>
          </div>
      <div class="control-group">
              <label class="control-label">注册时间</label>
              <div class="controls">
                <input type="text" name="gmt_create" readonly><br>
            </div>
          </div>
    </form>
    <div class="modal-footer">
      <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
    </div>
  </div>
  <script>
    function rechargeUser(){
      var form = new FormData(document.getElementById("rechargeUser"));
      $.ajax({
          url:"{:url('userdo/Recharge')}",
          type:"post",
          data:form,
          processData: false,                // jQuery不要去处理发送的数据
          contentType: false,
          dataType: 'json',
          success:function(data){
             if (0 == data.code) {
                // $("#UserInfo input[name='user_balance']").val(data.data.user_balance);
                alert("充值成功！");
                $('#recharge_user').modal('hide');
              }else{
                alert(data.msg);
              }
             
          }
      }); 
    }
  </script>
  <div id="recharge_user" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
      <h3 id="myModalLabel">充值</h3>
    </div>
    <form id="rechargeUser" class="form-horizontal" onsubmit="return false;" method="post">
      <br>
      <div class="control-group">
              <label class="control-label">充值金额</label>
              <div class="controls">
                <input type="text" name="recharge" placeholder="请输入充值金额" required><br>
            </div>
          </div>
    </form>
    <div class="modal-footer">
      <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
      <input class="btn" type="button" value="提交" onclick="rechargeUser();">
    </div>
  </div>
  
  <script>
     function applyCashUser(){
      var form = new FormData(document.getElementById("applyCashUser"));
      $.ajax({
          url:"{:url('userdo/applyCash')}",
          type:"post",
          data:form,
          processData: false,                // jQuery不要去处理发送的数据
          contentType: false,
          dataType: 'json',
          success:function(data){
             if (0 == data.code) {
                // $("#UserInfo input[name='user_balance']").value(data.data.user_balance);
                alert("提现成功！");
                $('#applyCash_user').modal('hide');
              }else{
                alert(data.msg);
              }
             
          }
      }); 
    }
  </script>
   <div id="applyCash_user" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
      <h3 id="myModalLabel">提现</h3>
    </div>
    <form id="applyCashUser" class="form-horizontal" onsubmit="return false;" method="post">
      <br>
      <div class="control-group">
              <label class="control-label">提现金额</label>
              <div class="controls">
                <input type="text" name="cash_num" placeholder="请输入提现金额" required><br>
            </div>
          </div>
    </form>
    <div class="modal-footer">
      <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
      <input class="btn" type="button" value="提交" onclick="applyCashUser();">
    </div>
  </div>
   {block name="model"}
   {/block}
    <!--Footer Block-->
    <section class="footer-wrapper">
      <footer class="container">
        
        <div class="footer-bottom-block">
          <p class="copyright-block">© 2016计算机科学与技术 <a href="http://www.baidu.com/" title="" target="_blank">点赚金</a></p>
        </div>
      </footer>
    </section>
</body>
</html>